package control

import (
	"WeChatMGRA/server/smodul"
	"gitee.com/yutiandou/wdtools/wdlog"
	"github.com/gin-gonic/gin"
	"strconv"
)

func SelectAll(g * gin.Context){
	offset,err := strconv.Atoi(g.PostForm("offset"))
	if wdlog.Error(err){
		g.JSON(400,"参数offset错误")
	}
	limit,err:= strconv.Atoi(g.PostForm("limit"))
	if wdlog.Error(err){
		g.JSON(400,"参数limit错误")
	}
	rs,err:=smodul.Get_All_Record(limit,offset)
	if wdlog.Error(err){
		g.JSON(500,"当前参数下查询错误")
	}
	resp_data := make([]string,0)
	for _,v:=range rs{
		data := v.CreatedAt.Format("2006-01-02 15:04:05") + ": " + v.RobotName + "->" + v.Customer +"->" + v.Event
		resp_data = append(resp_data,data)
	}
	g.JSON(200,resp_data)
}
